<?php
namespace app\common\model;
/**
* User模型
*/
class User extends BaseModel
{
	public function add($data = []){
		if(!is_array($data)){
			exception('传递的数据不是数组');
		}
		$data['status'] = 1;
		// $data['create_time'] = time();
		$this->allowField(true)->save($data);

		return $this->id;
	}

	//根据用户名获取用户信息
	public function getUserByUsername($username){
		if(!$username){
			exception('用户名不合法');
		}

		$data = ['username' => $username];

		return $this->where($data)->find();
	}
}